package com.springboot.mybatis;

import com.springboot.mybatis.dao.User;
import com.springboot.mybatis.service.UserService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
@MapperScan("com.springboot.mybatis.mapper")
public class Springboot04MybatisApplication {

    public static void main(String[] args) {

        ConfigurableApplicationContext applicationContext = SpringApplication.run(Springboot04MybatisApplication.class, args);
        UserService userService = applicationContext.getBean(UserService.class);
//        System.out.println(userService.insertuser(new User(null, "张三", "123456", "2020-01-01")));
//        System.out.println(userService.insertuser(new User(null, "李四", "123456", "2020-01-01")));
//        System.out.println(userService.insertuser(new User(null, "王五", "123456", "2020-01-01")));
        System.out.println(userService.selectuser(1L));
        System.out.println(userService.selectuser(2L));
        System.out.println(userService.selectuser(3L));
        applicationContext.close();
    }

}
